package handler

import (
	"github.com/gin-gonic/gin"
	"path/filepath"
	"post-hub/response"
)

func Upload(c *gin.Context) {
	file, err := c.FormFile("image")
	if err != nil {
		return
	}
	if file.Size > 1024*1024*2 {
		response.Error(c, "图片过大")
		return
	}
	ext := filepath.Ext(file.Filename)
	if ext != ".jpg" && ext != ".png" {
		response.Error(c, "图片格式不正确")
	}

}
